package br.ita.doacoes.view.voluntarios;

import java.util.Collections;
import java.util.List;

import javax.swing.DefaultComboBoxModel;



import br.ita.doacoes.core.templates.DAO;
import br.ita.doacoes.core.templates.DAOFactory;
import br.ita.doacoes.core.templates.GenericDAOJPA;
import br.ita.doacoes.domain.cadastrodoacoes.Pessoa;
import br.ita.doacoes.domain.voluntarios.Habilidade;
import br.ita.doacoes.view.cadastrodoacoes.refresher.Refreshable;
import br.ita.doacoes.view.cadastrodoacoes.refresher.Refresher;

public class PessoaCombo extends DefaultComboBoxModel implements Refreshable {

	DAO<Pessoa> dao = new GenericDAOJPA(Pessoa.class);
	
	public PessoaCombo(){
		refresh();
		Refresher.add(this);
	}
	
	public void refresh(){
		removeAllElements();
		List list = dao.getList();
		Collections.sort(list, new PessoaComparator());
		for(Object obj: list){
			addElement(obj);
		}
	}

}
